package com.fowo.api.controller.shipment.fbainvoice;

import com.fowo.api.controller.purchase.vo.WarehouseBinParam;
import com.fowo.api.controller.purchase.vo.WarehouseBinStockVo;
import com.fowo.api.model.fbainvoice.FBAInvoiceLockinventoryAction;
import com.fowo.api.model.fbainvoice.FBAInvoiceVo;
import com.fowo.api.model.fbainvoice.detail.FBAInvoiceDetailItemVo;
import com.fowo.api.service.impl.FBAInvoiceServiceImpl;
import com.fowo.api.service.impl.WarehouseBinDServiceImpl;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Component()
public class fbaInvoiceLockinventoryAction implements FBAInvoiceLockinventoryAction {

    @Resource
    private FBAInvoiceServiceImpl fbaInvoiceServiceImpl;
    @Resource
    private WarehouseBinDServiceImpl warehouseBinDServiceImpl;
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void run(List<Long> idList) throws Exception {
        for(int i=0;i<idList.size();i++){
            Long l = idList.get(i);
            suoku(l);
        }
    }

    private void suoku(Long l) throws Exception {
        FBAInvoiceVo voById = fbaInvoiceServiceImpl.getVoById(l);
        if(voById.getIslockinventory().equals("0")){

            //更新仓位信息
//            updatePosition(voById);

            fbaInvoiceServiceImpl.locksInventory(l);
            fbaInvoiceServiceImpl.lockpInventory(l);
            //修改为锁库存状态
            voById.setIslockinventory("1");
            fbaInvoiceServiceImpl.update(voById);
        }
    }


}
